Data Types
Conversions
The following is a matrix of supported by QQL data types for numerics and their conversions. The general conversion principle is that the higher priority always beats the lower priority: Int8 + Int16 = Int16.
tip
Note, that casting from higher to lower precision types causes data loss. For example cast from Int16 to Int8.
info
| Int8 | Int16 | Int32 | Int64 | Decimal64 | Float32 | Float64 | Timestamp | Timestamp(ns) | |
|---|---|---|---|---|---|---|---|---|---|
| Int8 | Int32 | Int32 | Int32 | Int64 | Decimal64 | Float32 | Float64 | Timestamp | Timestamp(ns) |
| Int16 | Int32 | Int32 | Int32 | Int64 | Decimal64 | Float32 | Float64 | Timestamp | Timestamp(ns) |
| Int32 | Int32 | Int32 | Int32 | Int64 | Decimal64 | Float32 | Float64 | Timestamp | Timestamp(ns) |
| Int64 | Int64 | Int64 | Int64 | Int64 | Decimal64 | Float32 | Float64 | Timestamp | Timestamp(ns) |
| Decimal64 | Decimal64 | Decimal64 | Decimal64 | Decimal64 | Decimal64 | Float32 | Float64 | - | - |
| Float32 | Float32 | Float32 | Float32 | Float32 | Float32 | Float32 | Float64 | - | - |
| Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | - | - |
| Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | - | - | - | Int64 | Int64 |
| Timestamp(ns) | Timestamp(ns) | Timestamp(ns) | Timestamp(ns) | Timestamp(ns) | - | - | - | Int64 | Int64 |
Operations with Timestamps
tip
0 = 1970-01-01 00:00:00.000 - Unix time in ms.
timestamp+-integer=timestamptimestamp-timestamp=Int64timestamp><== (compare)timestamp=booltimestamp(ns)+-integer=timestamp(ns)
In operations involving different resolutions (- or comparison operations), timestamps will be automatically converted to the most precise type timestamp(ns).
timestamp-timestamp(ns)=Int64timestamp(ms)><== (compare)timestamp(ns)=bool
SELECT '2022-10-10 10:10:10.010'd - '2022-10-10 10:10:10.000'd == 10
SELECT '2022-10-10 10:10:10.000'd + 10 == '2022-10-10 10:10:10.010'd
SELECT '2022-10-10 10:10:10.000'd + 1d5h == '2022-10-11 15:10:10.000'd
Operations with Arrays
When performing various operations with arrays of different types, the following principles apply:
Array(a) ◦ b = Array(type(a ◦ b))a ◦ Array(b) = Array(type(a ◦ b))Array(a) ◦ Array(b) = Array(type(a ◦ b))
where
a/b- data types◦- any operation
-- select all Entries array elements with Price fields and add 3 to each Price value
SELECT entries.price +3
Nullability Conversions
Any data field in QQL may be declared as nullable, regardless of its data type. If so declared, it may contain the special out-of-band value of NULL, which basically means "no data". Additionally, NULL values are generated by queries in special cases. A NULL value is formatted as an underscore character: "_", so it can be differentiated from an empty string. Unlike ORACLE, an empty string value is distinctly different from a NULL value.
Array elements can as well be nullable and not nullable.
When performing operations with two data types with different nullability, the following principle apply:
isNullable=true + isNullable=false = isNullable=true.
| True | False | |
|---|---|---|
| True | True | True |
| False | True | False |
info
Refer to Filtering to learn more about NaN and nullability.